import moment from 'moment'
import 'moment/locale/zh-cn'

function getDateText(timeStamp){
    let dateText = ''
    const now = moment()
    const before = moment(Number(timeStamp))
    const diff = moment.duration(now.diff(before))
    if(diff.years() > 0){
        dateText = before.format('YYYY-MM-DD HH:mm:ss')
    }else if(diff.months() > 0){
        dateText = before.format('YYYY-MM-DD HH:mm:ss')
    }else if(diff.days() > 0){
        dateText = before.format('YYYY-MM-DD HH:mm:ss')
    }else if(diff.hours() > 0){
        dateText = before.format('YYYY-MM-DD HH:mm:ss')
    }else{
        dateText = before.fromNow()
    }
    return dateText
}

export default getDateText